using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PT_SessionMap : EntityTypeConfiguration<PT_Session>
    {
        public PT_SessionMap()
        {
            // Primary Key
            this.HasKey(t => t.PTS_ID);

            // Properties
            this.Property(t => t.PTS_ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.PTS_Physician)
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("PT_Session");
            this.Property(t => t.PTS_ID).HasColumnName("PTS_ID");
            this.Property(t => t.PTS_Date).HasColumnName("PTS_Date");
            this.Property(t => t.PTS_Physician).HasColumnName("PTS_Physician");
            this.Property(t => t.PTS_PhysioID).HasColumnName("PTS_PhysioID");

            // Relationships
            this.HasOptional(t => t.PT_Physio)
                .WithMany(t => t.PT_Session)
                .HasForeignKey(d => d.PTS_PhysioID);
            this.HasOptional(t => t.Vend)
                .WithMany(t => t.PT_Session)
                .HasForeignKey(d => d.PTS_Physician);

        }
    }
}
